package com.jihui.jihuipicturebackend.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jihui.jihuipicturebackend.model.dto.space.SpaceAddRequest;
import com.jihui.jihuipicturebackend.model.dto.space.SpaceQueryRequest;
import com.jihui.jihuipicturebackend.model.dto.space.SpaceUpdateRequest;
import com.jihui.jihuipicturebackend.model.entity.Space;
import com.jihui.jihuipicturebackend.model.entity.User;
import com.jihui.jihuipicturebackend.model.vo.SpaceVO;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wu'ji'hui
 * @description 针对表【space(空间)】的数据库操作Service
 * @createDate 2025-02-09 13:59:12
 */
public interface SpaceService extends IService<Space> {

    /**
     * 创建空间
     *
     * @param spaceAddRequest
     * @param loginUser
     * @return
     */
    long addSpace(SpaceAddRequest spaceAddRequest, User loginUser);

    /**
     * 根据空间id删除空间
     *
     * @param spaceId
     * @return
     */
    boolean deleteSpaceById(Long spaceId);

    /**
     * 更新空间
     *
     * @param spaceUpdateRequest
     * @param loginUser
     * @return
     */
    SpaceVO updateSpace(SpaceUpdateRequest spaceUpdateRequest,
                        User loginUser);

    /**
     * 构造查询条件
     *
     * @param spaceQueryRequest
     * @return
     */
    QueryWrapper<Space> getSpaceQueryWrapper(SpaceQueryRequest spaceQueryRequest);

    /**
     * 获取单个空间的VO
     *
     * @param spaceQueryRequest
     * @return
     */
    SpaceVO getSpaceVO(SpaceQueryRequest spaceQueryRequest);

    /**
     * 获取单个空间的VO（分页）
     *
     * @param spacePage
     * @param httpServletRequest
     * @return
     */
    Page<SpaceVO> getSpaceListVO(Page<Space> spacePage, HttpServletRequest httpServletRequest);


    /**
     * 校验空间信息
     *
     * @param space
     */
    void validSpace(Space space, boolean add);

    /**
     * 根据空间等级填充空间信息
     *
     * @param space
     */
    void fillSpaceBySpaceLevel(Space space);

    /**
     * 检查空间权限
     *
     * @param space
     * @param loginUser
     */
    void checkSpaceAuth(Space space, User loginUser);

}
